package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ShopSoftware;
import com.ruoyi.system.service.IShopSoftwareService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 软件池列Controller
 * 
 * @author ruoyi
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/system/software")
public class ShopSoftwareController extends BaseController
{
    @Autowired
    private IShopSoftwareService shopSoftwareService;

    /**
     * 查询软件池列列表
     */
    @PreAuthorize("@ss.hasPermi('system:software:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopSoftware shopSoftware)
    {
        startPage();
        List<ShopSoftware> list = shopSoftwareService.selectShopSoftwareList(shopSoftware);
        return getDataTable(list);
    }

    /**
     * 导出软件池列列表
     */
    @PreAuthorize("@ss.hasPermi('system:software:export')")
    @Log(title = "软件池列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopSoftware shopSoftware)
    {
        List<ShopSoftware> list = shopSoftwareService.selectShopSoftwareList(shopSoftware);
        ExcelUtil<ShopSoftware> util = new ExcelUtil<ShopSoftware>(ShopSoftware.class);
        util.exportExcel(response, list, "软件池列数据");
    }

    /**
     * 获取软件池列详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:software:query')")
    @GetMapping(value = "/{softwareId}")
    public AjaxResult getInfo(@PathVariable("softwareId") Long softwareId)
    {
        return success(shopSoftwareService.selectShopSoftwareBySoftwareId(softwareId));
    }

    /**
     * 新增软件池列
     */
    @PreAuthorize("@ss.hasPermi('system:software:add')")
    @Log(title = "软件池列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopSoftware shopSoftware)
    {
        return toAjax(shopSoftwareService.insertShopSoftware(shopSoftware));
    }

    /**
     * 修改软件池列
     */
    @PreAuthorize("@ss.hasPermi('system:software:edit')")
    @Log(title = "软件池列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopSoftware shopSoftware)
    {
        return toAjax(shopSoftwareService.updateShopSoftware(shopSoftware));
    }

    /**
     * 删除软件池列
     */
    @PreAuthorize("@ss.hasPermi('system:software:remove')")
    @Log(title = "软件池列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{softwareIds}")
    public AjaxResult remove(@PathVariable Long[] softwareIds)
    {
        return toAjax(shopSoftwareService.deleteShopSoftwareBySoftwareIds(softwareIds));
    }
}
